package demo7;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Person implements InitializingBean {

    private String name;

    public Person() {
        System.out.println("1.Person的构造方法");
    }

    @Value("张三")
    public void setName(String name) {
        System.out.println("2.初始化name属性,setName()方法执行了");
        this.name = name;
    }

    public void play() {
        System.out.println("3.Person中的正常方法play()执行了");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("Person对象被容器初始化完毕了");
    }
}
